﻿/************************************************
*
* Copyright(c) ZeeGuo.com
*
* CLR : 4.0.30319.296
*
* FileName : Entity7k7kComicBook.cs
*
* Author : Kurodo
*
* CreatTime : 2013/7/18 15:48:44
*           
*************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using ComicSpider.Model;

namespace ComicSite
{
    public class Entity7k7kComicBook : EntityComicBook
    {
        protected override string GetBookName(string context)
        {
            return DataMatch.RegexsValue(context, "comicname = \"(\\w{1,50})", 1);
            //Regex regName = new Regex("g_comic_name = \"\\w{1,50}\";");
            //return regName.Matches(context)[0].Value;
        }

        protected override string GetChapterName(string context)
        {
            return DataMatch.RegexsValue(context, "viewname = \"(\\w{1,50})", 1);
            //Regex regChapter = new Regex("g_chapter_name = \"(\\w{1,50})\";");
            //return regChapter.Matches(context)[0].Value;
        }

        protected override int GetPageCount(string context)
        {
            return 0;
            //Regex regPage = new Regex("g_max_pic_count = \\d{1,3}\";");
            //return int.Parse(regPage.Matches(context)[0].Value);
        }

        public override List<string> GenerateComicPages(string context)
        {
            this.WebSiteUrl = "http://m.uimg.cn";
            Regex js = new Regex("imageslist\\[\\w{1,3}\\]='([\\s\\S]*?.jpg)';");
            MatchCollection collect = js.Matches(context);

            this.Comic_Pages = new List<string>();
            foreach (Match mat in collect)
            {
                this.Comic_Pages.Add(string.Format("{0}{1}", this.WebSiteUrl, mat.Groups[1].Value));
            }

            return this.Comic_Pages;
        }
    }
}
